home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.04 Apr 95 / TreeAppƒ / Eric's C++ Libraries / Interface Classes / CPPText.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-04  |  3.6 KB  |  129 lines  |  [TEXT/KAHL]

  1. /********************************************************* DEFINITION
  2.     DATE:    9/17/93
  3.     AUTHOR: Eric R. Rosé
  4.     
  5.     CLASS:  CPPText
  6.     
  7.     SUPERCLASS: CPPVisualObject
  8.     
  9.         This C++ class manages a textedit area, and a horizontal and
  10.         vertical scrollbar which let you adjust the text.
  11.     
  12. ********************************************************************/
  13.  
  14. #pragma once
  15.  
  16. #include <CPPVisualObject.h>
  17.  
  18. class CPPWindow;
  19.  
  20. class CPPText : public CPPVisualObject{
  21. public:
  22.                     CPPText (CPPWindow *OurWindow,
  23.                                   Rect *ViewArea,
  24.                                   Rect *DestArea,
  25.                                   short    maxLength = 32000,
  26.                                   Boolean UseHScroll = TRUE,
  27.                                   Boolean UseVScroll = TRUE,
  28.                                   short Font = geneva, 
  29.                                   short FSize = 9);
  30.                     CPPText (CPPWindow *OurWindow,
  31.                                   short    maxLength = 32000,
  32.                                   Boolean UseHScroll = TRUE,
  33.                                   Boolean UseVScroll = TRUE,
  34.                                   short Font = geneva, 
  35.                                   short FSize = 9);
  36.                     ~CPPText (void);
  37.  
  38.     virtual    Boolean    Member (char *className);
  39.     virtual    char     *ClassName (void);
  40.  
  41.     virtual    Boolean    DoCommand (short commandID);
  42.  
  43.     virtual    void    TypeChar (unsigned char TheKey);
  44.  
  45.     void            DoCut (void);
  46.     void            DoCopy (void);
  47.     virtual    void    DoPaste (void);
  48.     void            DoClear (void);
  49.     void            DoSelectAll (void);
  50.     
  51.             CharsHandle    GetTheText (void);
  52.             short        GetTextLen (void);
  53.     virtual    Boolean    DoKey (char theKey, short modifiers, short what);
  54.     virtual    void    Activate (Boolean nowActive);
  55.     virtual    Boolean DoClick (EventRecord *theEvent);
  56.     virtual    void    DoIdle (void);
  57.     virtual    Rect    *GetBounds (void);
  58.     
  59.     virtual    void    Draw (void);
  60.     virtual    void    MakeVisible (Boolean nowVisible);
  61.     virtual    void    TargetHilite (Boolean makeTarget);
  62.  
  63.     virtual    void     InsertTextPtr (Ptr theText, long textLen, 
  64.                                    long insertWhere, 
  65.                                    Boolean ScrollToInsertion);
  66.             void    InsertTextHandle (Handle theText, long textLen,
  67.                                       long where, 
  68.                                       Boolean ScrollToInsertion);
  69.     virtual    void     SetTextPtr (Ptr theText, long textLen,
  70.                                 Boolean ScrollToInsertion);
  71.             void     SetTextHandle (Handle theText, long textLen,
  72.                                    Boolean ScrollToInsertion);
  73.                                    
  74.     void            SetMinSize (short mwidth, short mheight);
  75.     void            SetMaxSize (short mwidth, short mheight);
  76.  
  77.     void             MoveScrollText (void);
  78.     
  79. protected:
  80.     TEHandle        TextBlock;
  81.     ControlHandle    HScroll;
  82.     ControlHandle     VScroll;
  83.     short            maxTextLen;
  84.  
  85.     virtual    void    ResizeContent (short newWidth, short newHeight);
  86.     virtual    void    MoveContent (short newH, short newV);
  87.  
  88.     void            CheckInsertion (void);
  89.       void            ScrollChar (short charPos, Boolean toBottom);
  90.     
  91. private:
  92.     short            TEminWidth,
  93.                     TEmaxWidth,
  94.                     TEminHeight,
  95.                     TEmaxHeight;
  96.                     
  97.     static    CPPText        *gCurrentTE;
  98.     static    ControlHandle    gVScroll;
  99.     static    ControlHandle    gHScroll;
  100.     static    TEHandle        gTextBlock;
  101.                     
  102.     // static class methods
  103.     static pascal Boolean AutoScroll (void);
  104.     static pascal void Scroll_Right (ControlHandle theControl, 
  105.                                         short ctlPart);
  106.     static pascal void Scroll_Left (ControlHandle theControl, 
  107.                                         short ctlPart);
  108.     static pascal void Scroll_Up (ControlHandle theControl, 
  109.                                         short ctlPart);
  110.     static pascal void Scroll_Down (ControlHandle theControl, 
  111.                                         short ctlPart);
  112.  
  113.     void            MakeTEArea (CPPWindow *OurWindow,
  114.                                 Rect *ViewArea,
  115.                                 Rect *DestArea,
  116.                                 short    maxLength,
  117.                                 Boolean UseHScroll,
  118.                                 Boolean UseVScroll,
  119.                                 short    Font,
  120.                                 short    FSize);
  121.     long             LinesInWindow(void);
  122.     long            LinesInText (void);
  123.     void            VPageScroll (long part, long direction);
  124.     void            HPageScroll (long part, long direction);
  125.     void            AdjustScrollBar (void);
  126.     void             DoVScroller (Point clickPt, short part);
  127.     void            DoHScroller (Point clickPt, short part);
  128.  
  129. };